package reseaux.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class LireTexte {
	public static void main(String[] args) 
	{
		
		String serverName = "www.seroths.com";
		String text = "";
		try {
			Socket sock = new Socket(serverName, 80);
			
			
			PrintWriter out = 
					new PrintWriter(sock.getOutputStream(), true);
			out.print("Je suis un message");
			out.flush();
			
			BufferedReader in = new BufferedReader
					(new InputStreamReader(sock.getInputStream()));
			text += in.readLine();
			
			sock.close();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("Message lu: "+text);
	}
}
